﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace pttk_htt_hr.Utility
{
    class Util
    {
        
        public static bool Compare_ListSqlParameter_Dictionary(List<SqlParameter> LstSqlparam, Dictionary<string, string> Dic)
        {
            bool isEqual = false;
            for (int paramI = 0; paramI < LstSqlparam.Count; paramI++)
            {
                string ParamName = LstSqlparam[paramI].ParameterName;
                
                //Remove @
                ParamName.Remove(0, 1);

                if (Dic.ContainsKey(ParamName))
                {
                    string ParamVal = LstSqlparam[paramI].Value.ToString();

                    if (Dic[ParamName].Equals(ParamVal))
                    {
                        isEqual = true;
                    }

                }
            }

            return isEqual;
        }

        public static string ConvertFormat_FromStringDate(string strSource, string desFormat)
        {
            string res = "";

            if (!String.IsNullOrEmpty(strSource))
            {
                res = DateTime.Parse(strSource).ToString(desFormat);

            }

            return res;
        }

    }
}
